package org.platform.core.filecommand.impl;

import com.mc.mic.core.log.bus.BusLogPusher;
import com.mc.mic.core.log.frame.LogBo;
import com.mc.mic.core.tool.helper.SpringContextHelper;
import lombok.extern.slf4j.Slf4j;
import org.platform.constant.LogType;
import org.platform.core.filecommand.IFileCommand;
import org.platform.mo.bussmo.log.OperationMqBO;
import org.platform.processor.knowledge.KnowledgePublishReceiveProcessor;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author FengJie
 * @date 2018/6/21
 */
@Slf4j
public class KnowPublishFileCommand implements IFileCommand {
    @Autowired
    private KnowledgePublishReceiveProcessor processor;
    @Autowired
    private BusLogPusher mqLog;

    public KnowPublishFileCommand() {
        if (null == processor) {
            processor = SpringContextHelper.getBean(KnowledgePublishReceiveProcessor.class);
        }
        if (null == mqLog) {
            mqLog = SpringContextHelper.getBean(BusLogPusher.class);
        }
    }

    @Override
    public boolean doCommandAck(String filePath, String fileName, String txtMsg) {

        String operation = "接收到知识审核发布响应文件,正在执行知识发布响应流程";
        mqLog.log(new LogBo<>(LogType.OPERATION_LOG, new OperationMqBO(operation)));
        log.info(operation);
        processor.knowledgePublish(txtMsg);
        return true;
    }
}
